package quartz;

import org.quartz.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author guo
 */
@Configuration
public class QuartzConfig {


    @Bean
    public JobDetail teatQuartzDetail(){
        return JobBuilder.newJob(SampleJob.class).withIdentity("sampleJob").storeDurably().build();
    }
    @Bean
    public Trigger testQuartzTrigger(){
        //设置时间周期单位秒
        SimpleScheduleBuilder scheduleBuilder = SimpleScheduleBuilder.simpleSchedule()
                .withIntervalInSeconds(1)
                .repeatForever();
        return TriggerBuilder.newTrigger().forJob(teatQuartzDetail())
                .withIdentity("sampleJob")
                .withSchedule(scheduleBuilder)
                .build();
    }

}
